import java.util.concurrent.atomic.AtomicBoolean;

public class InterruptDemo3 {
    public static void main(String[] args) {
        AtomicBoolean atomicBoolean = new AtomicBoolean(false);
        new Thread(() -> {
            while (true) {
                if (atomicBoolean.get()) {
                    System.out.println("线程被中断");
                    break;
                }
                System.out.println("线程执行中...atomicBoolean");
            }
        }, "t1").start();

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        atomicBoolean.set(true);
    }
}
